# 导入pymysql模块
import pymysql

# 连接database
conn = pymysql.connect(host='10.129.83.241', port=3306, user='chefutest'
                       , password='chefutest', database='chefu_order', charset='utf8')
# 得到一个可以执行SQL语句的光标对象
cursor = conn.cursor()
sql = "SELECT * FROM ORDER_MAIN LIMIT 1"

try:
    # 执行SQL语句
    cursor.execute(sql)
    result = cursor.fetchall()
    print(cursor.description)
    for desc in cursor.description:
        print(desc);

    for r in result:
        # print(type(r))
        for rs in r:
            print(rs)


except Exception as e:
    # 有异常，回滚事务
    conn.rollback()
cursor.close()
conn.close()
